package com.ruike.alisurface.ui.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ruike.alisurface.R;
import com.voodoo.lib_utils.imageLoader.GlideImageLoader;
import com.voodoo.lib_utils.imageLoader.transformation.RoundedCornersTransformation;

import java.util.List;

public class PrescriptionAdapter extends BaseQuickAdapter<String, BaseViewHolder> {


    Context mContext;

    public PrescriptionAdapter(@Nullable List<String> data, Context context) {
        super(R.layout.item_prescription, data);
        mContext = context;
    }


    public boolean ishidedel = false;

    public boolean isIshidedel() {
        return ishidedel;
    }

    public void setIshidedel(boolean ishidedel) {
        this.ishidedel = ishidedel;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        ImageView del = helper.getView(R.id.prescription_del);
        ImageView prescription_img = helper.getView(R.id.prescription_img);
        if (!item.equals("")) {
            GlideImageLoader.getInstance().loadRoundCircleImage(mContext, item, prescription_img,
                    10, RoundedCornersTransformation.CornerType.ALL);
            if (isIshidedel()) {
                del.setVisibility(View.INVISIBLE);
            } else {
                del.setVisibility(View.VISIBLE);
                del.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        setOnItemChildClick(view, helper.getLayoutPosition());
                    }
                });
            }
        } else {
            del.setVisibility(View.GONE);
            GlideImageLoader.getInstance().loadImage(mContext, R.drawable.icon_img_add, prescription_img);
        }
        //获取当前item的position
        //int position = helper.getLayoutPosition();

    }
}

